#include "setPositionMessage.h"
#include "jsonUtils.h"

SetPositionMessage::SetPositionMessage(MtpProtocol* packet) : MtpMessage(packet),position(0)
{
}

SetPositionMessage::SetPositionMessage(const int64_t& movieId, const int& scene, const int& position)
	: MtpMessage(new MtpProtocol(L"setPosition")), param(movieId, scene), position(position)
{
}

void SetPositionMessage::decodeBody()
{
	MtpMessage::decodeBody();
	JsonDoc& doc = param.jsonDeserialize(jsonContent);
	JsonUtils::loadInt(doc, L"position", position);
}

void SetPositionMessage::encodeBody()
{
	JsonDoc& doc = param.jsonSerialize();
	doc.AddMember(L"position", position, doc.GetAllocator());
	jsonContent = JsonUtils::jsonStr(doc);
	MtpMessage::encodeBody();
}

const int64_t& SetPositionMessage::getMovieId()
{
	return param.getMovieId();
}

const int& SetPositionMessage::getPosition()
{
	return position;
}
